/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2018
 */

package com.bm.console.business.impl;

import com.sys.object.common.page.PageBean;

import com.bm.console.business.WebStateService;
import com.bm.console.pojo.WebState;
import com.bm.console.pojo.mapper.WebStateMapper;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sys.object.common.page.PageBean;

@Service
public class WebStateServiceImpl implements WebStateService {

    @Autowired
    WebStateMapper webStateMapper;

    @Override
    public PageBean queryPageList(WebState entity, PageBean page) throws Exception {
        int rowCount = webStateMapper.selectByPageCount(entity);
        page.setRowCount(rowCount);
        entity.setOffset(page.getStartRow());
        entity.setLimit(page.getPerpage());
        page.setList(webStateMapper.selectByPage(entity));
        return page;
    }

    public WebState queryByPrimaryKey(Integer id) throws Exception {
        return webStateMapper.selectByPrimaryKey(id);
    }

    public int saveOrUpdate(WebState entity) throws Exception {
        if (entity.getId() != null && entity.getId() > 0) {
            return this.webStateMapper.updateByPrimaryKeySelective(entity);
        }
        return this.webStateMapper.insert(entity);
    }

    public int remove(Integer id) throws Exception {
        return this.webStateMapper.deleteByPrimaryKey(id);
    }

    public int delete(Integer id) throws Exception {
        return this.webStateMapper.deleteByPrimaryKey(id);
    }

    public int updateStatus(WebState entity) throws Exception {
        return this.webStateMapper.updateByPrimaryKeySelective(entity);
    }

    public int updateStatus(String status, String[] ids) throws Exception {
        return 0;
    }

    @Override
    public List<WebState> selectAll() {
        return webStateMapper.selectAll();
    }
}
